; =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
;  Author: Florian Muecke
;  Copyright: Florian Muecke, 2005
;  Description: main include file for Easy Installation System
; =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

;----INCLUDES------------------------
    include windows.inc
    include gdi32.inc
    include user32.inc
    include kernel32.inc
    include Comctl32.inc
    include masm32.inc
    include ole32.inc
    include oleaut32.inc
    include unrar.inc
    include advapi32.inc

    includelib gdi32.lib
    includelib user32.lib
    includelib kernel32.lib
    includelib Comctl32.lib
    includelib masm32.lib
    includelib ole32.lib
    includelib oleaut32.lib
    includelib advapi32.lib


;----PROTOTYPES--------------------------
    Wizard          PROTO
    WelcomeDlg      PROTO   :DWORD,:DWORD,:DWORD,:DWORD
    NfoDlg          PROTO	:DWORD,:DWORD,:DWORD,:DWORD
    SettingsDlg     PROTO   :DWORD,:DWORD,:DWORD,:DWORD
    ExtractDlg      PROTO	:DWORD,:DWORD,:DWORD,:DWORD
    ConsoleDlg      PROTO	:DWORD,:DWORD,:DWORD,:DWORD
    LoadResFile     PROTO   :DWORD,:DWORD,:DWORD
    PaintProc       PROTO   :DWORD,:DWORD,:DWORD,:DWORD
    BrowseProc      PROTO   :DWORD,:DWORD,:DWORD,:DWORD
    ListBoxProc     PROTO   :DWORD,:DWORD,:DWORD,:DWORD
    SpaceCheck      PROTO   :DWORD
    RARCallbackProc	PROTO   :DWORD,:DWORD,:DWORD,:DWORD
    udw2str         PROTO   :DWORD,:DWORD
    ErrorCode       PROTO   :DWORD,:DWORD
    AboutMenu       PROTO   :DWORD

;----MACROS-------------------------------
    m2m MACRO M1, M2
        push M2
        pop  M1
    ENDM

    return MACRO arg
	   mov eax, arg
	   ret
    ENDM

	szText MACRO Name, Text:VARARG
		LOCAL lbl
		jmp lbl
			Name db Text,0
		lbl:
	ENDM

;----CONSTANTS------------------------------
.const

    IDD_NFO         equ 1000
    IDD_CONSOLE		equ 2000
    IDD_EXTRACT	    equ 3000
    IDD_WELCOME     equ 4000
    IDD_SETTINGS    equ 5000
    IDB_WIZARD		equ 100
    IDB_LOGO        equ 101
    PSM_SETHEADERSUBTITLE   equ WM_USER+127

    oneMeg          DD 1048576
    
    ;----flags------------------
    FLAG_SCSMENU   equ 1
    FLAG_SCDESKTOP equ 2   
    FLAG_LIC_READ   equ 4


;----VARIABLES------------------------------
.data

    caption         DB "Easy Installation System",0
    RunFile         DB "\setup.bat",022h,0
    RunFile2        DB " /e:4096 /c ",022h,0
    ComSpec         DB "ComSpec",0
    envFile         DB "\~EIS\env.bat",0
    doneFile        DB "\~EIS\done",0
    hEnvFile        dd 0
    ShellFoldersKey	DB "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders",0
    KeyDesktop      DB "Common Desktop",0
    KeySMenu        DB "Common Programs",0
    phkResult		DD 0
    lpdwDisp		DD 0
    env             DB ":generated by EIS",13,10
                    DB "SET CD=",MAX_PATH*2 dup (0) ;enough space to get %cd% within
    envDesktop      DB 13,10,"SET DESKTOP=",0
    envWindir       DB 13,10,"SET WINDIR=",0
    envSCuts        DB 13,10,"SET SHORTCUTS=",0
    envSMenu        DB 13,10,"SET SMENU=",0
    ;;envSMenuFolder  DB 13,10,"SET SMENUFOLDER=",0

    FontName        DB "Terminal",0
    FontName2       DB "Verdana Bold",0
    lFont           LOGFONT <0>
    lFont2          LOGFONT <0>
    ;msg             MSG <0>
    abort_thread    DB 0FEh     ;flag used to signalise the extract-thread that it should exit
    flags           DD 0        ;bitmask for different settings - see constants 

    root            DB "[\]",0
    patn            DB "*.*",0
    nFormatStr      DB "%lu MB",0
    nFormatStr2     DB "%i%%",0
    tmpStr          DB "~EIS%i\",0
    titleKey        DB "title",0
    sizeKey         DB "size",0
    fileKey         DB "file",0
    pathKey         DB "path",0
    dirKey          DB "dir",0
    patchKey        DB "patch",0
    shortcutsKey    DB "shortcuts",0
    ;;smenufolderKey  DB "smenufolder",0
    resName1        DB "unpacker.dll",0 ;unrar.dll
    resName2        DB "eis.ini",0      ;eis.ini
    resName3        DB "readme.txt",0  ;eis.nfo

    ;----language specific include files---------
    include english.inc     ;english text strings
    ;include german.inc     ;german text strings


    ;----RAR functions------------------------------
    strRCloseArchive        DB "RARCloseArchive",0
    strROpenArchive         DB "RAROpenArchive",0
    strRProcessFile         DB "RARProcessFile",0
    strRReadHeader          DB "RARReadHeader",0
    strRSetCallback         DB "RARSetCallback",0
    strRSetChangeVolProc    DB "RARSetChangeVolProc",0
    strRSetProcessDataProc  DB "RARSetProcessDataProc",0
    strRSetPassword         DB "RARSetPassword",0
    RCloseArchive           DD 0
    ROpenArchive            DD 0
    RProcessFile            DD 0
    RReadHeader             DD 0
    RSetCallback            DD 0
    RSetChangeVolProc       DD 0
    RSetProcessDataProc     DD 0
    RSetPassword            DD 0

    nMBytesReq              DD 0
    nBytesFree              DQ 0
    nMBytesFree             DD 0
    nBytesReq               DQ 0
    FileCRC                 DD 0
    nBytesExtracted         DD 0
    nOverallBytesExtracted  DQ 0

    ;----empty-data-&-handles---------------
    ArchiveData     RAROpenArchiveData <>
    HeaderData      RARHeaderData <>
    patchSize       DD 0
    hInstance       dd 0
    hPs             DD 5 dup(0)
    hPsDlg		    DD 5 dup(0)
    hPropSheet      DD 0
    hArchive        DD 0
    nfoAddress      DD 0
    nfoSize         DD 0
    hBrushBack      DD 0
    hFont           DD 0
    hFont2          DD 0
    hwndEdit        DD 0
    hDll            DD 0
    hLogo_big       DD 0
    hLogo           DD 0
    hExtract        DD 0
    dummy_dd        DD 0
    ThreadID        DD 0
    hThread         DD 0
    hWndBrowse      DD 0
    hList           DD 0
    lpLstBox        DD 0
    
    ;----buffers------------------------
    targetDir       DB MAX_PATH dup(0)  ; base application path
    targetDirName   DB 160 dup(0)       ; name for the application's directory
    srcDir          DB MAX_PATH dup(0)
    strBuffer       DB MAX_PATH*2 dup(0)  ; a buffer
    tmpDir          DB MAX_PATH dup(0)
    ArcName         DB 64 dup(0)        ;max 64 chars!!
    PatchName       DB 64 dup(0)        ;max 64 chars!!
    AppTitle        DB 128 dup(0)       ;max 128 chars!!
    

